package com.e9where.canpoint.customrecycler.recycler.item;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;

/**
 * Created by Administrator on 2017/12/1.
 * //底部布局
 */

public class CustomFoot extends FrameLayout{

    private TextView textView;

    public CustomFoot(@NonNull Context context) {
        super(context);
        init();
    }

    private void init() {
        setClickable(false);
        textView = new TextView(getContext());
        //文字颜色
        textView.setTextColor(Color.parseColor("#666666"));
        //背景颜色
        textView.setBackgroundColor(Color.parseColor("#f1f1f1"));
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);
        textView.setText("加载中...");
        addView(textView, new LayoutParams(LayoutParams.MATCH_PARENT, dip2px(50)));
    }

    //设置刷新动画的大小
    private  int dip2px(int dipValue) {
        float scale = getContext().getResources().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }

    //加载中...
    public void onLoad()
    {
        textView.setText("加载中...");
    }

    public void onFinish()
    {
        textView.setText("刷新完成");
    }

    public void onMore()
    {
        textView.setText("没有更多。");
    }
}
